home *** CD-ROM | disk | FTP | other *** search
/ Download Now 8 / Download Now V8.iso / Program / InternetTools / ApacheWebServer1.3.6 / apache_1_3_6_win32.exe / _SETUP.1 / regfree.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-15  |  796 b   |  39 lines

  1. #include <sys/types.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #include "hsregex.h"
  6. #include "utils.h"
  7. #include "regex2.h"
  8.  
  9. /*
  10.  - regfree - free everything
  11.  = API_EXPORT(void) regfree(regex_t *);
  12.  */
  13. ap_private_extern
  14. API_EXPORT(void)
  15. regfree(preg)
  16. regex_t *preg;
  17. {
  18.     register struct re_guts *g;
  19.  
  20.     if (preg->re_magic != MAGIC1)    /* oops */
  21.         return;            /* nice to complain, but hard */
  22.  
  23.     g = preg->re_g;
  24.     if (g == NULL || g->magic != MAGIC2)    /* oops again */
  25.         return;
  26.     preg->re_magic = 0;        /* mark it invalid */
  27.     g->magic = 0;            /* mark it invalid */
  28.  
  29.     if (g->strip != NULL)
  30.         free((char *)g->strip);
  31.     if (g->sets != NULL)
  32.         free((char *)g->sets);
  33.     if (g->setbits != NULL)
  34.         free((char *)g->setbits);
  35.     if (g->must != NULL)
  36.         free(g->must);
  37.     free((char *)g);
  38. }
  39.